/*
 * @lc app=leetcode.cn id=387 lang=csharp
 *
 * [387] 字符串中的第一个唯一字符
 */

// @lc code=start
public class Solution {
    public int FirstUniqChar(string s) {
        var dict = new Dictionary<char, int>();
        foreach (var c in s)
        {
            if (!dict.ContainsKey(c))
            {
                dict[c] = 1;
            }
            else
            {
                dict[c] += 1;
            }
        }
        for (int i = 0; i < s.Length; ++i)
        {
            if (dict[s[i]] == 1)
            {
                return i;
            }
        }
        return -1;
    
        
    }
}
// @lc code=end

